package com.example.smartclassroom.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.smartclassroom.entity.Admin;
import com.example.smartclassroom.entity.dto.UserInfoDTO;
import com.example.smartclassroom.entity.form.LoginForm;
import com.example.smartclassroom.mapper.AdminMapper;
import com.example.smartclassroom.service.AdminService;
import com.example.smartclassroom.util.LoginUserInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;
    //登录
    public Admin login(LoginForm loginForm) {
        Admin login = adminMapper.login(loginForm);
        if(login!=null){
            return login;
        }
        throw  new RuntimeException("账号密码错误");
    }
    //注册
    public int register(LoginForm loginForm) {
        return adminMapper.insert(loginForm);
    }
    //编辑用户信息
    public int update(Admin admin) {
        return adminMapper.update(admin);
    }


}
